The EXTRACT_SLICE function extracts a specified planar slice of volumetric data. This function allows for a rotation or vector form of the slice equation. In the vector form, the slice plane is governed by the plane equation (ax+by+cz+d = 0) and a single vector which defines the x direction. This form is more common throughout the IDL polygon interface. In the rotation form, the slicing plane can be oriented at any angle and can pass through any desired location in the volume.
This function allows for a vertex grid to be generated without sampling the data. In this form, the vertices could be used to sample additional datasets or used to form polygonal meshes. It would also be useful to return the planar mesh connectivity in this case.
Support for anisotropic data volumes is included via an ANISOTROPY keyword. This is an important feature in the proper interpolation of common medical imaging data.
This routine is written in the IDL language. Its source code can be found in the file extract_slice.pro in the lib subdirectory of the IDL distribution.
Result = EXTRACT_SLICE( Vol, Xsize, Ysize, Xcenter, Ycenter, Zcenter, Xrot, Yrot, Zrot [, ANISOTROPY=[xspacing, yspacing, zspacing]] [, OUT_VAL=value] [, /RADIANS] [, /SAMPLE] [, VERTICES=variable] )
or
Result = EXTRACT_SLICE( Vol, Xsize, Ysize, Xcenter, Ycenter, Zcenter, PlaneNormal, Xvec [, ANISOTROPY=[xspacing, yspacing, zspacing]] [, OUT_VAL=value] [, /SAMPLE] [, VERTICES=variable] )
Returns a two-dimensional planar slice extracted from 3-D volumetric data or returns a vertex grid in the form of a [3,n] array of vertices.
Set this input argument to a 3 element array. The values are interpreted as the normal of the slice plane.
Set this input argument to a 3 element array. The three values are interpreted as the 0 dimension directional vector. This should be a unit vector.
The volume of data to slice. This argument is a three-dimensional array of any type except string or structure. The planar slice returned by EXTRACT_SLICE has the same data type as Vol.
The desired X size (dimension 0) of the returned slice. To preserve the correct aspect ratio of the data, Xsize should equal Ysize. For optimal results, set Xsize and Ysize to be greater than or equal to the largest of the three dimensions of Vol.
The desired Ysize (dimension 1) of the returned slice. To preserve the correct aspect ratio of the data, Ysize should equal Xsize. For optimal results, set Xsize and Ysize to be greater than or equal to the largest of the three dimensions of Vol.
The X coordinate (index) of the point within the volume that the slicing plane passes through. The center of the slicing plane passes through Vol at the coordinate (Xcenter, YCenter, Zcenter).
The Y coordinate (index) of the point within the volume that the slicing plane passes through. The center of the slicing plane passes through Vol at the coordinate (Xcenter, YCenter, Zcenter).
The Z coordinate (index) of the point within the volume that the slicing plane passes through. The center of the slicing plane passes through Vol at the coordinate (Xcenter, YCenter, Zcenter).
The X-axis rotation of the slicing plane, in degrees. Before transformation, the slicing plane is parallel to the X-Y plane. The slicing plane transformations are performed in the following order:
The Y-axis rotation of the slicing plane, in degrees.
The orientation Z-axis rotation of the slicing plane, in degrees.
Set this keyword to a three-element array. This array specifies the spacing between the planes of the input volume in grid units of the (isotropic) output image.
Set this keyword to a value that will be assigned to elements of the returned slice that lie outside of the original volume.
Set this keyword to indicate that Xrot, Yrot, and Zrot are in radians. The default is degrees.
Set this keyword to perform nearest neighbor sampling when computing the returned slice. The default is to use bilinear interpolation. A small reduction in execution time results when SAMPLE is set and the OUT_VAL keyword is not used.
Set this output keyword to a named variable in which to return a [3,Xsize,Ysize] floating point array. This is an array of the x, y, z sample locations for each pixel in the normal output.
Display an oblique slice through volumetric data:
; Create some data:
vol = RANDOMU(s, 40, 40, 40)
; Smooth the data:
FOR i=0, 10 DO vol = SMOOTH(vol, 3)
; Scale the smoothed part into the range of bytes:
vol = BYTSCL(vol[3:37, 3:37, 3:37])
; Extract a slice:
slice = EXTRACT_SLICE(vol, 40, 40, 17, 17, 17, 30.0, 30.0, 0.0, $
OUT_VAL=0B)
; Display the 2D slice as a magnified image:
TVSCL, REBIN(slice, 400, 400)
Note: Also see “Planar Slicing of Volumetric Data” (Chapter 2, Image Processing in IDL)in the help/pdf
directory of your IDL installation for a more extensive example.
Pre 4.0 |
Introduced |
Pre 6.1 |
Deprecated the CUBIC keyword |